clear all
set more off
cap log close

ssc install unique
    
global dir "/Replication Archive"
cd "${dir}"

global outreg_settings = " label bdec(4) pvalue pdec(3) tex(frag) excel  nor2 nonotes "


************************************
************* TABLE A6 *************
************************************

use "${dir}/Data/Final Datasets/Final_Data_Director_MC_Level_DEF2.dta", clear

gen donated=(amount_noself>0)

bys DirectorID: egen max_donated=max(donated)
keep if max_donated==1

replace donated=donated*1000

unique CompanyID
local unique_company: display %5.4fc `r(unique)' 

collapse (max) donated relevant, by(DirectorID cycle icpsr2 chamber)

egen double Director_MC=group(DirectorID icpsr2 chamber)
egen double Congress_MC=group(icpsr2 chamber cycle)
egen double Congress_Director=group(DirectorID cycle chamber)

unique DirectorID 
local unique_directors: display %5.4fc `r(unique)' 
unique icpsr2 
local unique_MC: display %5.4fc `r(unique)' 

reghdfe donated relevant, noabsorb cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA6", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_MC) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA6", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_MC Congress_MC) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA6", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_MC Congress_MC Congress_Director) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA6", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons
